package internal

import (
	"gorm.io/gorm"
)

type DB struct {
	*gorm.DB
}

func (d *DB) Close() {
	db, _ := d.DB.DB()
	db.Close()
}

func (d *DB) GetTx() *gorm.DB {
	return d.DB
}

func (d *DB) Exist(tx *gorm.DB) (bool, error) {
	var cnt int64
	err := tx.Count(&cnt).Error
	if cnt > 0 {
		return true, nil
	}
	return false, err
}
